package com.methods;
/**
 *汽车类
 *  2017/8/16
 *  @author Erik
 *  @version 0.1
 *  @since JDK1.8.
 */
public class Car {
    private String color;
    private String userName;

    public Car(){}
    public Car(String color,String userName){
        this.setColor(color);
        this.setUserName(userName);
    }

    //setters
    public void setColor(String color)      {    this.color = color; }
    public void setUserName(String userName) {      this.userName = userName;   }

    //getters
    public String getColor()    {   return this.color;  }
    public String getUserName() {   return this.userName;   }

    public void use(){
        System.out.println("我是机动车");
    }

    public boolean equals(Object obj){
        if(obj==null)  return false;

        Car car=(Car) obj;

        return this.getUserName().equals(car.getUserName()) && this.getColor().equals(car.getColor());

        /*
        if(this.getColor()==car.getColor() && this.getUserName()==car.getUserName())
            return true;
        else
            return false
         */
    }
}
